import { post, get } from '../../http/axios'

export default {
    namespaced: true,
    state: {
        data: {},
        data_username: {},
    },
    mutations: {
        set_usermanagement(state, val) {
            state.data = val;
        },

        set_isUsermanagement(state, val) {
            state.data_username = val;
        }
    },
    actions: {
        async find_user({ commit }, params) {
            let res = await get('/baseUser/pageQuery', params);
            commit('set_usermanagement', res.data)
        },
        //用来查询用户名是否重复
        async find_isUser({ commit }, params) {
            let res = await get('/baseUser/pageQuery', params);
            commit('set_isUsermanagement', res.data)
        },
        async delete_user({ commit }, params) {
            let res = await get('/baseUser/deleteById', params);
            return res;
        },


        async change_user({ commit }, params) {
            let res = await post('/baseUser/saveOrUpdate', params);
            return res;
        },

        //给用户设置权限
        async set_authority({ commit }, params) {
            let res = await post('/baseUser/setRoles', params);
            return res;
        },

        //给用户设置超级管理员
        async set_rivilege({ commit }, params) {
            let res = await post('/privilege/saveOrUpdate', params);
            return res;
        },

    }
}